<template>
	<view class="immediate">
		<!-- 点击立即提现跳转到此-->
		<u-navbar leftIconSize="34rpx" autoBack :placeholder="true" bgColor="#ffffff">
			<view slot="center">
				<text class="c-000 pf-sc fw-600" style="font-size: 34rpx;">提现</text>
			</view>
		</u-navbar>
		<!--  -->
		<view
			class="authentication-container w-750 b-box  bg-fa po-re"
			style="padding-top: 20rpx;"
			:style="{ height: containerHeight }"
			v-if="!applyStatus"
		>
			<view
				class="d-flex flex-c ali-i-s just-s b-box w-100 bg-ff"
				style="padding: 36rpx 32rpx 20rpx;border-bottom: 1rpx solid #eaeaea;"
			>
				<text
					class="pf-sc fw-400"
					style="font-size: 30rpx;color: rgba(0,0,0,0.9000);margin-bottom: 20rpx;"
				>
					提现金额
				</text>
				<view class="d-flex flex-r ali-i-c just-s w-100 b-box">
					<text class="fw-400 pf-sc c-333" style="font-size: 38rpx;margin-right: 15rpx;">¥</text>
					<u-input
						border="none"
						placeholder="最低提现金额不少于100元"
						:customStyle="{ color: '#222222', font: '400 30rpx PingFang SC' }"
						v-model="money"
					></u-input>
				</view>
			</view>

			<!--  -->
			<view class="w-100 b-box bg-ff" style="height: 35rpx;margin-bottom: 20rpx;"></view>
			<!--  -->
			<view
				class="w-100  bg-ff b-box po-re"
				style="padding: 36rpx 38rpx 0rpx 36rpx;margin-bottom: 80rpx;height: 204rpx;"
			>
				<view
					class="w-100 b-box d-flex flex-r ali-i-c just-sw po-re"
					style="margin-bottom: 50rpx;"
					v-if="datainfo.name"
				>
					<text class="pf-sc fw-400 " style="color: rgba(0,0,0,0.9000);font-size: 30rpx;">
						<text style="margin-right: 50rpx;">提现账号</text>
						<text>{{ datainfo.name }}</text>
					</text>
				</view>

				<view v-if="datainfo.name" style="width: 300rpx;height: 300rpx;">
					<image
						v-if="datainfo.txcode"
						:src="'https://www.chejingjing.cn' + datainfo.txcode"
						mode="widthFix"
						style="width: 326rpx;height: 326rpx;"
					></image>
				</view>

				<view
					v-if="!datainfo.name"
					class="po-ab w-100 d-flex flex-r ali-i-e just-c b-box"
					style="height:110rpx"
					@click="Add"
				>
					<text
						class="pf-sc fw-400"
						style="font-size: 30rpx;color: #26387C;margin-right: 30rpx;margin-bottom: 40rpx;"
					>
						+ 添加提现账户
					</text>
				</view>
			</view>

			<!--  -->
			<view
				class="w-100 b-box d-flex flex-r ali-i-c just-c"
				style="margin-top: 600rpx;"
			>
				<u-button
					:throttleTime="700"
					@click="getAtixian"
					:customStyle="{
						height: '88rpx',
						width: '670rpx',
						font: '400 32rpx PingFang SC',
						color: '#ffffff',
						borderWidth: '0rpx',
						background: 'linear-gradient(180deg, #4885C5 0%, #3B52A6 100%)',
						borderRadius: '44rpx'
					}"
					shape="square"
					text="提交"
				></u-button>
			</view>
		</view>
		<view v-else :style="{ height: containerHeight }" class=" w-750 b-box bg-fa">
			<view
				class="authentication-container w-750 b-box d-flex flex-c ali-i-c just-c  bg-fa po-re"
				:style="{ height: parseInt(containerHeight) / 2 + 'px' }"
				v-if="passThrough"
			>
				<image
					src="../static/succrss.png"
					style="width: 198rpx;height: 198rpx;margin: 88rpx 0 32rpx;"
				></image>
				<text class="pf-sc fw-500" style="font-size: 34rpx;color: #222222;margin-bottom: 16rpx;">
					提现申请已提交
				</text>
				<text class="pf-sc fw-400" style="font-size: 26rpx;color: #666666;margin-bottom: 68rpx;">
					您的提现申请已提交，等待平台审核
				</text>
				<u-button
					:throttleTime="700"
					plain
					@click="GoStaffHome"
					:customStyle="{
						height: '74rpx',
						width: '240rpx',
						font: '400 32rpx PingFang SC',
						color: '#333333',
						borderWidth: '0rpx',
						borderRadius: '44rpx',
						border: '1rpx solid #dcdcdc'
					}"
					shape="square"
					text="返回首页"
				></u-button>
			</view>

			<view
				class="authentication-container w-750 b-box d-flex flex-c ali-i-c just-c  bg-fa po-re"
				:style="{ height: parseInt(containerHeight) / 2 + 'px' }"
				v-else
			>
				<image
					src="../static/fail2.png"
					style="width: 198rpx;height: 198rpx;margin: 88rpx 0 32rpx;"
				></image>
				<text class="pf-sc fw-500" style="font-size: 34rpx;color: #222222;margin-bottom: 16rpx;">
					提现申请失败
				</text>
				<text class="pf-sc fw-400" style="font-size: 26rpx;color: #666666;margin-bottom: 68rpx;">
					失败原因描述
				</text>
				<u-button
					:throttleTime="700"
					plain
					@click="GoStaffHome"
					:customStyle="{
						height: '74rpx',
						width: '240rpx',
						font: '400 32rpx PingFang SC',
						color: '#333333',
						borderWidth: '0rpx',
						borderRadius: '44rpx',
						border: '1rpx solid #dcdcdc'
					}"
					shape="square"
					text="返回首页"
				></u-button>
			</view>
		</view>
	</view>
</template>

<script>
import { _containerHeight, _addUnit, _rpxTpx } from '@/utils/GetSys.js';
import Unavbar from '../components/uview-ui/components/u-navbar/u-navbar';
import Ubutton from '../components/uview-ui/components/u-button/u-button';
import uInput from '../components/uview-ui/components/u-input/u-input';
import { txcode, tixian } from '@/common/api.js';
export default {
	components: {
		'u-navbar': Unavbar,
		'u-button': Ubutton,
		'u-input': uInput
	},
	data() {
		return {
			containerHeight: '',
			fileList1: [],
			applyStatus: false, //是否审核状态
			passThrough: false, //审核状态中是否申请成功
			datainfo: null,
			money: ''
		};
	},
	methods: {
		getindexcont() {
			txcode({
				token: uni.getStorageSync('usertoken')
			})
				.then(res => {
					if (res.data.code === 1) {
						this.datainfo = res.data.data;
						console.log(this.datainfo, 'datainfo');
					}
				})
				.catch(err => {});
		},
		getAtixian() {
			if (!this.datainfo.name) {
				uni.showToast({
					icon: 'none',
					title: '请添加提现账户'
				});
				return false;
			}
			if (!this.money) {
				uni.showToast({
					icon: 'none',
					title: '请输入提现金额'
				});

				return false;
			}
			if (this.money < 100) {
				return uni.showToast({
					title: '提现金额小于100元',
					icon: 'none'
				});
			}
			tixian({
				token: uni.getStorageSync('user').token,
				name: this.datainfo.name,
				image: this.datainfo.txcode,
				money: this.money
			})
				.then(res => {
					// console.log(res, '我是用户端的');
					if (res.data.code === 1) {
						console.log(res.data.data);
						uni.showToast({
							icon: 'none',
							title: res.data.msg
						});

						this.applyStatus = true;
						this.passThrough = true; //申请成功状态
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						});
					}
				})
				.catch(err => {});
		},

		Add() {
			//添加提现账户
			uni.redirectTo({
				url: '/staffModelA/staffC/AddWithdrawalAccount/AddWithdrawalAccount'
			});
		},
		GoStaffHome() {
			uni.switchTab({
				url: '/pages/UserHomePage/UserHomePage'
			});
		},
		Back() {
			uni.redirectTo({
				url: '/staffModelA/staffC/WithdrawalAccount/WithdrawalAccount'
			});
		}
	},
	onLoad() {
		this.containerHeight = _containerHeight();
		this.getindexcont();
	}
};
</script>

<style lang="scss">
.immediate {
}
</style>
